package com.strive.oauth2.store;

import com.strive.oauth2.properties.SecurityProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.security.oauth2.provider.token.TokenStore;

/**
 * @description:
 * @author: bingcun.chen
 * @Date: 2022/3/3 11:23
 * @Version 1.0
 */
@Configuration
@ConditionalOnProperty(prefix = "strive.oauth2.token.store", name = "type", havingValue = "redis", matchIfMissing = true)
public class AuthRedisTokenStore {
    @Bean
    public TokenStore tokenStore(RedisConnectionFactory connectionFactory, SecurityProperties securityProperties, RedisSerializer<Object> redisValueSerializer){
        return new CustomRedisTokenStore(connectionFactory, securityProperties, redisValueSerializer);
    }
}
